package com.osmap.openstreetmap.ui.fragment;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.osmap.openstreetmap.R;
import com.osmap.openstreetmap.adapter.FootmarkAdapter;
import com.osmap.openstreetmap.bean.FootMark;
import com.osmap.openstreetmap.json.FootmarkJson;
import com.osmap.openstreetmap.ui.BaseFragment;

public class Collection extends BaseFragment {

	private ListView mList;
	private FootmarkJson mJson;

	private List<FootMark> mJsonList;

	private FootmarkAdapter mAdapter;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.fragment_footmark, container,
				false);
		initView(view);
		return view;
	}

	private void initView(View view) {
		mList = (ListView) view.findViewById(R.id.lv_footmark);
		mJson = new FootmarkJson();
		FootMark footmark = null;
        Random random = new Random();
		mJsonList = new ArrayList<FootMark>();
		for (int i = 0; i < 10; i++) {
			footmark = new FootMark();
            footmark.title = "风华正茂" + i;
			footmark.fromString = i+"分钟前 来自一键分享";
            footmark.progress = random.nextInt(4);
			mJsonList.add(footmark);
		}

		mJson.list = mJsonList;
		mAdapter = new FootmarkAdapter(mJson, getActivity());
		mList.setAdapter(mAdapter);
	}
}
